Textures provide images that can be used with image nodes, texture brushes and materials for use in 3D rendering or material brushes. More...
#include <kanzi/core.ui/graphics2d/texture.hpp>
Classes | |
| struct | CreateInfo |
| Struct which contains all the parameters that are needed for texture creation. More... | |
| struct | CreateInfo2D |
| Texture creation parameters for two dimensional texture. More... | |
| struct | CreateInfoCubemap |
| Texture creation parameters for cubemap texture that is initialized from six images. More... | |
| struct | CreateInfoCubemapRenderTarget |
| Use Texture::CreateInfoCubemapRenderTarget to create a Cubemap Render Target Texture resource. More... | |
| struct | CreateInfoHostCopy2D |
| Texture creation parameters for two dimensional texture that is updated from the CPU. More... | |
| struct | CreateInfoRenderTarget |
| Texture creation parameters for texture that can be used as render target for 2D nodes. More... | |
Public Member Functions | |
| void | connectToFramebufferColor (Framebuffer &framebuffer, size_t attachmentIndex) |
| Connects the texture into color attachment of a framebuffer. | |
| void | connectToFramebufferDepthStencil (Framebuffer &framebuffer) |
| Connects the texture into a depth attachments of a framebuffer. | |
| void | connectToFramebufferResolveColor (Framebuffer &framebuffer, size_t attachmentIndex) |
| Connects the texture into color resolve attachment of a framebuffer. | |
| void | connectToFramebufferResolveDepthStencil (Framebuffer &framebuffer) |
| Connects the texture into a resolve depth attachments of a framebuffer. | |
| void | generateMipmaps () const |
| Generates the mipmaps from the base level image. | |
| RenderbufferSharedPtr | getColorRenderbuffer () const |
| Returns internal color renderbuffer used for rendering, if one exists. | |
| Sampler::CreateInfo | getCurrentSamplerCreateInfo () const |
| Gets the current sampler create information. | |
| GraphicsFormat | getDepthStencilFormat () const |
| Returns depth/stencil format of the texture. | |
| RenderbufferSharedPtr | getDepthStencilRenderbuffer () const |
| Returns internal depth/stencil renderbuffer used for rendering, if one exists. | |
| Framebuffer * | getFramebuffer () const |
| Gets the framebuffer used for rendering. | |
| gfx::ImageHandleGuard | getHandle () const |
| Gets Kanzi graphics image handle for the texture. | |
| unsigned int | getHeightDivisor () const |
| Gets height divisor for automatic sizes. | |
| BitmapImageSharedPtr | getHostCopyImage () const |
| Returns the host-side memory copy of a non-cubemap texture, if available. | |
| BitmapImageSharedPtr | getHostCopyImage (Face face, size_t slice) const |
| Returns the host-side memory copy of texture data as an image, if available. | |
| NativeDeploymentTarget | getNativeDeploymentTarget () const |
| Gets the native deployment target. | |
| size_t | getOverrideSamplerCreateInfoCount () const |
| Gets the number of overrides in the sampler create info stack. | |
| const Sampler & | getSampler () const |
| Returns the Sampler used by the texture. | |
| gfx::SamplerHandleGuard | getSamplerHandle (Renderer &renderer) |
| Gets the current sampler handle guard for the texture. | |
| TextureType | getType () const |
| Gets type of the texture. | |
| gfx::ImageUsageFlag | getUsageFlags () const |
| Returns texture usage flags. | |
| unsigned int | getWidthDivisor () const |
| Gets width divisor for automatic sizes. | |
| bool | hasAutomaticHeight () const |
| Indicates whether height is or should be automatically calculated. | |
| bool | hasAutomaticWidth () const |
| Indicates whether width is or should be automatically calculated. | |
| bool | isRenderTargetTransient () const |
| Indicates whether render target buffers are transient. | |
| void | popOverrideSamplerCreateInfo () |
| Pups the topmost sampler create info into the override stack. | |
| void | pushOverrideSamplerCreateInfo (Sampler::CreateInfo createInfo) |
| Pushes an overriding sampler create info into the override stack. | |
| void | reattachFramebuffer () |
| Reattaches the internal framebuffer object. | |
| void | reattachFramebuffer (RenderbufferSharedPtr colorRenderbuffer) |
| Reattaches the internal framebuffer object and includes the renderbuffer given as parameter. | |
| void | reattachFramebuffer (TextureSharedPtr depthTexture) |
| Reattaches the internal framebuffer object and includes the depth texture given as parameter. | |
| void | recreate (CreateInfo &createInfo) |
| Validates the CreateInfo texture descriptor, creates a new texture and swaps it in place. | |
| void | resize (size_t width, size_t height) |
| Changes the size of the texture. | |
| void | resolveMSAA (Renderer &renderer) const |
| Resolves the internal multisample anti-aliasing renderbuffer to a single sample texture, if necessary. | |
| void | setData (const kanzi::byte *data) |
| Sets the texture data for base level of a non-cubemap texture. | |
| void | setData (Face face, size_t mipmapLevel, size_t x, size_t y, size_t width, size_t height, const kanzi::byte *data) |
| Sets the texture data for the specified area in a texture. | |
| void | setData (size_t mipmapLevel, size_t x, size_t y, size_t width, size_t height, const kanzi::byte *data) |
| Sets the texture data for the specified area in the texture. | |
| void | setHeightDivisor (unsigned int divisor) |
| Sets the height divisor. | |
| void | setWidthDivisor (unsigned int divisor) |
| Sets the wight divisor. | |
Public Member Functions inherited from kanzi::Surface | |
| size_t | getFaceCount () const |
| Get number of faces. This should be six for cubemaps and one for everything else. | |
| GraphicsFormat | getFormat () const |
| Get GraphicsFormat of Surface. | |
| size_t | getHeight () const |
| Get height in pixels. | |
| size_t | getMipmapLevelCount () const |
| Get number of mipmap levels. | |
| size_t | getRenderTargetSampleCount () const |
| Get number of multisample samples for Surface. | |
| size_t | getSliceCount () const |
| Get number of slices. | |
| size_t | getWidth () const |
| Get width in pixels. | |
Public Member Functions inherited from kanzi::GPUResource | |
| void | destroy () |
| Destroys a GPU resource. | |
| size_t | getGPUMemoryUsage () const |
| Gets the amount of GPU memory used by the resource. | |
| Renderer * | getRenderer () const |
| void | invalidate () |
| Notify resource that graphics context was lost and all GPU resources are invalid. | |
| bool | isDeployed () const |
| ~GPUResource () override | |
Public Member Functions inherited from kanzi::Resource | |
| size_t | getCPUMemoryUsage () const |
| Gets the amount of CPU memory used by the resource. | |
| const string & | getName () const |
| Gets the resource name. | |
| const string & | getUrl () const |
| Gets the resource URL. | |
| bool | isKeepAlive () const |
| Tells if the resource has keep alive flag set. | |
| void | reload () |
| void | reloadFromFile (string_view filePath) |
| void | reloadFromKzb (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser) |
| void | setKeepAlive (bool keepAlive) |
| Sets the keep alive flag. | |
| void | setUrl (string_view url) |
| Sets the resource URL. | |
| ~Resource () override | |
| Destructor. | |
Public Member Functions inherited from kanzi::Object | |
| AppliedStyleEntrySharedPtr | applyObjectStyle (kanzi::StyleSharedPtr style) |
| Applies a style to an object. | |
| void | applyObjectStyles () |
| Apply all styles for an object node. | |
| Domain * | getDomain () const |
| Returns the domain the object belongs to. | |
| const Metaclass * | getDynamicMetaclass () const override |
| Returns the metaclass of the dynamic type of the object. | |
| MainLoopScheduler * | getMainLoopScheduler () const |
| Returns the MainLoopScheduler instance of the associated Domain. | |
| detail::MessageDispatcher * | getMessageDispatcher () const |
| Returns the message dispatcher of the object. | |
| ResourceManager * | getResourceManager () const |
| Returns the resource manager of the object. | |
| ScriptingContextSharedPtr | getScriptingContext () const |
| Gets the scripting context of the object. | |
| Object (Domain *domain) | |
| void | setScriptingContext (ScriptingContextSharedPtr context) |
| Sets the scripting context of the object. | |
| void | unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry) |
| void | unapplyObjectStyles () |
| Unapplies and removes all applied styles. | |
| ~Object () override | |
Public Member Functions inherited from kanzi::MetaObject | |
| bool | isTypeOf (const Metaclass *objectType) const |
| Determines if the type of this object is the given type or derived from it. | |
| virtual | ~MetaObject () |
Public Member Functions inherited from kanzi::PropertyObject | |
| template<typename DataType > | |
| void | addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
| Adds a property modifier. | |
| template<typename DataType > | |
| void | addPropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
| Adds a property modifier without notifying handlers. | |
| template<typename DataType > | |
| void | addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
| template<typename DataType > | |
| void | addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner) |
| template<typename DataType > | |
| void | addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer) |
| PropertyStorageContainer::iterator | beginPropertyStorage () |
| Returns the begin iterator to the internal property storage container. | |
| PropertyStorageContainer::const_iterator | beginPropertyStorage () const |
| Returns the begin iterator to the internal property storage container. | |
| void | clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
| void | copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType) |
| Copies local value of single property from another object. | |
| void | copyLocalValues (const PropertyObject &other) |
| Copies all local values from another object. | |
| PropertyStorageContainer::iterator | endPropertyStorage () |
| Returns the end iterator to the internal property storage container. | |
| PropertyStorageContainer::const_iterator | endPropertyStorage () const |
| Returns the end iterator to the internal property storage container. | |
| template<typename DataType > | |
| PropertyType< DataType >::Traits::ReturnType | getAbstractProperty (AbstractPropertyType abstractPropertyType) const |
| template<typename DataType > | |
| PropertyType< DataType >::Traits::ReturnType | getAbstractPropertyBase (AbstractPropertyType abstractPropertyType) const |
| template<typename DataType > | |
| optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const |
| template<typename DataType > | |
| optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalProperty (const PropertyType< DataType > &propertyType) const |
| Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. | |
| template<typename DataType > | |
| optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalPropertyBase (const PropertyType< DataType > &propertyType) const |
| Returns the current value of a property disregarding modifiers, but does not default to the value in property metadata if there are no inputs to the property value. | |
| template<typename DataType > | |
| PropertyType< DataType >::Traits::ReturnType | getProperty (const PropertyType< DataType > &propertyType) const |
| Returns the current value of a property type. | |
| template<typename DataType > | |
| PropertyType< DataType >::Traits::ReturnType | getPropertyBase (const PropertyType< DataType > &propertyType) const |
| Returns the current value of a property disregarding modifiers. | |
| template<typename DataType > | |
| size_t | getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) const |
| Gets number of current notification handlers for given property type. | |
| bool | hasBaseValue (AbstractPropertyType propertyType) const |
| Evaluates whether there are any inputs into the property value, disregarding modifiers. | |
| bool | hasLocalValue (AbstractPropertyType propertyType) const |
| Evaluates whether there is a local value set for the property. | |
| bool | hasNonClassValue (AbstractPropertyType propertyType) const |
| Evaluates whether there is a value of any precedence higher than class default value set for the property. | |
| bool | hasValue (AbstractPropertyType propertyType) const |
| Evaluates whether there are any inputs into the property value. | |
| bool | isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const |
| virtual void | onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason) |
| Virtual function to handle property change notifications. | |
| PropertyObject () | |
| void | removeKzbProperties () |
| Remove all KZB properties. | |
| void | removeKzbProperties (flat_set< AbstractPropertyType > *keepProperties) |
| Remove all KZB properties that are not included in a given set. | |
| template<typename DataType > | |
| void | removeLocalPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer) |
| void | removeLocalValue (AbstractPropertyType propertyType) |
| Removes the local value associated with the property. | |
| template<typename DataType > | |
| void | removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
| Removes a property modifier. | |
| template<typename DataType > | |
| void | removePropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
| Removes a property modifier without notifying handlers. | |
| template<typename DataType > | |
| void | removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
| template<typename DataType > | |
| void | removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer) |
| template<typename DataType > | |
| void | setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
| template<typename DataType > | |
| void | setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
| Sets the local value of a property type. | |
| void | setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
| void | validatePropertyModifiersAndNotifyHandlers (AbstractPropertyType propertyType) |
| Validates property modifiers and notifies handlers. | |
| virtual | ~PropertyObject () |
Static Public Member Functions | |
| static TextureSharedPtr | create (Domain *domain, const CreateInfo &createInfo, string_view name) |
| Creates a texture with specified texture creation parameters. | |
| static TextureSharedPtr | create (Domain *domain, TextureType type, const gfx::NativeTextureHandle &nativeHandle, bool takeOwnership, GraphicsFormat format, unsigned int mipmapLevelCount, unsigned int width, unsigned int height, string_view name) |
| Creates texture from a pre-existing image object. | |
| static ResourceManager::LoadTaskSharedPtr | createGenericFileLoadTask (string_view name, unique_ptr< File > file, Domain *domain) |
| Create a task used to create a Texture from generic file. | |
| static ResourceManager::LoadTaskSharedPtr | createLoadTask (string_view name, KzbFile *kzbFile, ReadOnlyMemoryFilePtr file) |
| Create a task used to create a Texture from KZB File. | |
Static Public Member Functions inherited from kanzi::Object | |
| static const Metaclass * | getStaticMetaclass () |
| Returns the metaclass of Object class. | |
| static PropertyTypeEditorInfoSharedPtr | makeEditorInfo () |
| Default implementation that returns empty editor info. | |
Static Public Member Functions inherited from kanzi::MetaObject | |
| static const Metaclass * | getStaticMetaclass () |
| Returns the metaclass of Object class. | |
| static PropertyTypeEditorInfoSharedPtr | makeEditorInfo () |
| Default implementation that returns empty editor info. | |
Static Protected Member Functions | |
| static vector< BitmapImageSharedPtr > | makeHostCopyImages (const CreateInfo &createInfo) |
| Helper function to allocate host images. | |
Protected Attributes | |
| GraphicsFormat | m_depthStencilFormat |
| Depth/Stencil format. | |
| size_t | m_faceCount |
| Number of texture faces. | |
| GraphicsFormat | m_format |
| Format of the texture handle. | |
| FramebufferPtr | m_framebuffer |
| Framebuffer necessary for compositing into the texture. | |
| size_t | m_height |
| Texture height. | |
| unsigned int | m_heightDivisor |
| Divisor for automatic height determination, 0 for no automatic height. | |
| gfx::ImageHandleGuard | m_imageHandle |
| Kanzi graphics image handle. | |
| vector< BitmapImageSharedPtr > | m_images |
| Copy of texture data, provides host CPU access without reading back from GPU. | |
| MemoryType | m_memoryType |
| Memory type for texture. | |
| size_t | m_mipmapLevelCount |
| Number of mipmap levels in the texture. | |
| NativeDeploymentTarget | m_nativeDeploymentTarget |
| Native memory storage for the texture. | |
| vector< Sampler::CreateInfo > | m_overrideSamplerSettings |
| Overriding sampler create info. | |
| size_t | m_rendertargetSampleCount |
| Number of implicit multisample samples. | |
| bool | m_renderTargetTransient |
| Transient flag for renderbuffers generated for off-screen rendering. | |
| Sampler | m_sampler |
| Sampler configuration. | |
| string | m_samplerName |
| Name to use with the sampler(s) for this texture. | |
| size_t | m_sliceCount |
| Reserved for future use. | |
| TextureType | m_type |
| Texture type. | |
| gfx::ImageUsageFlag | m_usageFlags |
| Image usage flags. | |
| size_t | m_width |
| Texture width. | |
| unsigned int | m_widthDivisor |
| Divisor for automatic width determination, 0 for no automatic height. | |
Protected Attributes inherited from kanzi::Object | |
| AppliedStyleContainer | m_appliedStyles |
| Listing of applied styles applied to this object. | |
Friends | |
| class | ResourceManager |
| void | swap (Texture &texture1, Texture &texture2) |
| Swaps two textures. | |
Additional Inherited Members | |
Public Types inherited from kanzi::Surface | |
| enum | APIAttachment { APIAttachmentColor0 , APIAttachmentColor1 , APIAttachmentColor2 , APIAttachmentColor3 , APIAttachmentDepth , APIAttachmentStencil , APIAttachmentCount , APIAttachmentInvalid } |
| enum | Face { FacePositiveX , FaceNegativeX , FacePositiveY , FaceNegativeY , FacePositiveZ , FaceNegativeZ , FaceDefault } |
| Texture face enumeration. More... | |
Public Types inherited from kanzi::GPUResource | |
| enum | MemoryType { GpuOnly , GpuAndRam , RamOnly } |
| Memory upload and RAM preservation strategy for GPU resources. More... | |
Public Types inherited from kanzi::PropertyObject | |
| using | PropertyStorageConstIterator |
| using | PropertyStorageContainer |
| using | PropertyStorageIterator |
| using | PropertyStoragePtr |
| using | PropertyStorageReverseIterator |
Protected Types inherited from kanzi::Object | |
| typedef vector< AppliedStyleEntrySharedPtr > | AppliedStyleContainer |
| Applied style container. | |
Textures provide images that can be used with image nodes, texture brushes and materials for use in 3D rendering or material brushes.
Textures can be set as render target. Texture can be set to as render target for either 2d node or render pass, but not both.
For details on the render target texture, see CreateInfoRenderTarget.
Texture can optionally maintain CPU accessible copy of texture data. See CreateInfoHostCopy2D for CPU accessible texture data details.
In order to create a texture, you must prepare Texture::CreateInfo structure and make sure it is valid using CreateInfo::validate(), then create the texture with Texture::create(). If texture creation parameters are not valid, Texture::create() will throw an exception, which can stop program execution.
Two dimensional textures can be created from Image or by specifying size, format and features. Cubemap textures can be created from six Images or by specifying size, format and features.
You must specify texture filtering, addressing mode (also known as wrap mode), and mipmap settings in Texture::CreateInfo before you create the texture. Two dimensional textures which are shown without scaling can be created with default texture creation parameters, which improve performance and reduce memory usage. If you show texture content with scaling, consider using linear filtering and prefiltered mipmaps to reduce aliasing, with some performance and memory cost.
To create a two dimensional texture from image:
To load image from file and create texture:
To access the image data after you create a texture:
To create a two dimensional texture from image with custom sampler settings:
To create a cubemap texture from 6 face images:
Examples - Loading textures with Kanzi C++ API using ResourceManager
To load texture with ResourceManager using file URL:
To load texture with ResourceManager:
To update texture data of two dimensional texture base level image:
To update texture data of cubemap texture all mipmap level images:
To use texture as render target for 2D node:
To use texture as render target for renderpass:
To create a two dimensional texture and render to it through framebuffer:
To create a two dimensional texture with mipmaps and render to it through framebuffer:
To create a cubemap texture with mipmaps and render to it through framebuffers:
|
explicitprotected |
Creates texture from CreateInfo.
Texture will be deployed, if createInfo memory type includes Gpu.
|
explicitprotected |
Creates texture from an existing GL object handle.
Caller must also provide texture format, and size. glHandle should be a valid GL texture object. Optionally, kanzi::Texture can take ownership of the provided GL texture object, in which case destroying kanzi::Texture will also destroy the GL texture object. If ownership is not passed to kanzi::Texture, then GL texture must be deleted after kanzi::Texture. Do not delete GL texture object while kanzi::Texture exists.
| domain | Domain for texture. |
| type | Texture type. |
| nativeHandle | Pre-existing valid GL texture object name. |
| format | Format of the texture. |
| mipmapLevelCount | Mipmap level count of the texture. |
| width | Width of the texture. |
| height | Height of the texture. |
| takeOwnership | Indicates whether kanzi::Texture should take ownership of provided GL texture object. |
| name | Name. |
|
inlinestatic |
Creates a texture with specified texture creation parameters.
In order to create a texture, you will need a CreateInfo structure that is filled with valid combination of texture creation parameters. You can use CreateInfo, CreateInfo2D, CreateInfoHostCopy2D, CreateInfoRenderTarget, CreateInfoCubemap and CreateInfoCubemapRenderTarget constructors to create and initialize a texture creation parameter structure. After calling the constructor you can fine tune texture creation parameters.
You can check that parameters are valid by calling CreateInfo::validate().
If you pass CreateInfo that is not valid, Texture::create() will throw an exception and program execution may will terminate. To avoid exceptions for recoverable errors, use Renderer::adjust() on the create info prior to calling this function.
If createInfo memory type includes Gpu, texture will be deployed.
If createInfo memory type includes Ram, host copy of texture data will be made accessible. Otherwise, texture host copy will not be accessible.
| domain | Domain for the texture. |
| createInfo | Texture creation parameters. |
| name | Name for the texture. |
|
inlinestatic |
Creates texture from a pre-existing image object.
Optionally, kanzi::Texture can take ownership of the provided image object, in which case destroying kanzi::Texture will also destroy the image object. If ownership is not passed to kanzi::Texture, then image must be deleted after kanzi::Texture. Do not delete image object while kanzi::Texture exists.
| domain | Domain. |
| type | Texture type. |
| nativeHandle | NativeTextureHandle element which is containing information for pre-existing image object. |
| takeOwnership | If true, texture will take ownership of the native resource (image object). |
| format | Format of the texture. |
| mipmapLevelCount | Number of mipmap levels in the texture. |
| width | Width of the texture. |
| height | Height of the texture. |
| name | Name. |
Returns the Sampler used by the texture.
|
inline |
Gets the current sampler create information.
This is either the current topmost overriding info or the one from the base sampler.
|
inline |
Pushes an overriding sampler create info into the override stack.
| createInfo | Overriding sampler create info. |
|
inline |
Pups the topmost sampler create info into the override stack.
|
inline |
Gets the number of overrides in the sampler create info stack.
| gfx::SamplerHandleGuard kanzi::Texture::getSamplerHandle | ( | Renderer & | renderer | ) |
Gets the current sampler handle guard for the texture.
This is either the default sampler for the texture, or an overridden sampler from the renderer.
|
inline |
Gets type of the texture.
|
inline |
Gets the native deployment target.
| void kanzi::Texture::reattachFramebuffer | ( | ) |
Reattaches the internal framebuffer object.
Only renderbuffers and the color texture within the texture object will be used.
| void kanzi::Texture::reattachFramebuffer | ( | RenderbufferSharedPtr | colorRenderbuffer | ) |
Reattaches the internal framebuffer object and includes the renderbuffer given as parameter.
The texture does not take ownership of the renderbuffer. The texture must not have an internal color texture.
| colorRenderbuffer | Renderbuffer to use as the color target in the framebuffer. |
| void kanzi::Texture::reattachFramebuffer | ( | TextureSharedPtr | depthTexture | ) |
Reattaches the internal framebuffer object and includes the depth texture given as parameter.
The texture does not take ownership of the depth texture. The texture must not have an internal depth render buffer.
| depthTexture | Depth texture to use as the depth target in the framebuffer. |
| void kanzi::Texture::generateMipmaps | ( | ) | const |
Generates the mipmaps from the base level image.
This reads from Gpu texture data from the base level images, and only updates Gpu texture data of the remaining mipmap images. If texture has host copy data, it remains unchanged.
| void kanzi::Texture::setData | ( | Face | face, |
| size_t | mipmapLevel, | ||
| size_t | x, | ||
| size_t | y, | ||
| size_t | width, | ||
| size_t | height, | ||
| const kanzi::byte * | data ) |
Sets the texture data for the specified area in a texture.
The texture data is updated to the GPU memory, and to the CPU accessible copy of the texture, if the texture is created with such storage.
| face | Which texture face to update. |
| mipmapLevel | Which mipmap level to update. |
| x | Specifies the x-coordinate of the texture. |
| y | Specifies the y-coordinate of the texture. |
| width | Specifies the width of the texture. |
| height | Specifies the height of the texture. |
| data | Texture data. |
| void kanzi::Texture::setData | ( | size_t | mipmapLevel, |
| size_t | x, | ||
| size_t | y, | ||
| size_t | width, | ||
| size_t | height, | ||
| const kanzi::byte * | data ) |
Sets the texture data for the specified area in the texture.
The texture data is updated to the GPU memory, and to the CPU accessible copy of the texture, if the texture is created with such storage.
| mipmapLevel | Which mipmap level to update. |
| x | Specifies the x-coordinate of the texture. |
| y | Specifies the y-coordinate of the texture. |
| width | Specifies the width of the texture. |
| height | Specifies the height of the texture. |
| data | Texture data. |
Sets the texture data for base level of a non-cubemap texture.
| data | Texture data. |
| gfx::ImageHandleGuard kanzi::Texture::getHandle | ( | ) | const |
Gets Kanzi graphics image handle for the texture.
|
inline |
Returns depth/stencil format of the texture.
|
inline |
Gets the framebuffer used for rendering.
This function is intended for inspecting the internal Texture Framebuffer state.
|
inline |
Returns internal color renderbuffer used for rendering, if one exists.
|
inline |
Returns internal depth/stencil renderbuffer used for rendering, if one exists.
| void kanzi::Texture::connectToFramebufferColor | ( | Framebuffer & | framebuffer, |
| size_t | attachmentIndex ) |
Connects the texture into color attachment of a framebuffer.
Use this function if using this texture as a part of combined rendering using multiple textures. The texture must be a color texture to support the connection. For connecting to resolve attachment, use connectToFramebufferResolveColor().
| framebuffer | Target framebuffer. |
| attachmentIndex | Target attachment index. |
| void kanzi::Texture::connectToFramebufferResolveColor | ( | Framebuffer & | framebuffer, |
| size_t | attachmentIndex ) |
Connects the texture into color resolve attachment of a framebuffer.
Use this function if you are using this texture as a part of combined rendering using multiple textures. The texture must be a color texture to support the connection. If this texture is not a suitable resolve target, the resolve target in the framebuffer is cleared. For connecting to draw attachment, use connectToFramebufferColor().
| framebuffer | Target framebuffer. |
| attachmentIndex | Target attachment index. |
| void kanzi::Texture::connectToFramebufferDepthStencil | ( | Framebuffer & | framebuffer | ) |
Connects the texture into a depth attachments of a framebuffer.
Use this function if using this texture as a part of combined rendering using multiple textures. The texture must have a depth/stencil renderbuffer or be a depth texture to support the connection. For connecting to resolve attachment, use connectToFramebufferResolveDepthStencil().
| framebuffer | Target framebuffer. |
| void kanzi::Texture::connectToFramebufferResolveDepthStencil | ( | Framebuffer & | framebuffer | ) |
Connects the texture into a resolve depth attachments of a framebuffer.
Use this function if you are using this texture as a part of combined rendering using multiple textures. The texture must be a depth texture to support the connection. If this texture is not a suitable resolve target, the resolve target in the framebuffer is cleared. For connecting to draw attachment, use connectToFramebufferDepthStencil().
| framebuffer | Target framebuffer. |
| BitmapImageSharedPtr kanzi::Texture::getHostCopyImage | ( | Face | face, |
| size_t | slice ) const |
Returns the host-side memory copy of texture data as an image, if available.
Returns as an image the copy of the host-side memory of the texture data, but does not create a copy of that image. Use this function only to retrieve data that was sent to the GPU from the CPU memory. To retrieve data rendered to a texture by the GPU use captureScreenToImage().
| face | The texture face for which you want to get the data. For single textures, this value is FaceDefault. For cubemap textures, use a valid face for the texture. For example, FacePositiveX, or FaceNegativeZ. If you try to access an invalid texture face, the function throws an exception. |
| slice | The texture slice for which you want to get the data. Slice applies to array and 3D textures. Currently this parameter must always be 0. If you access an invalid texture slice, the function throws an exception. |
| BitmapImageSharedPtr kanzi::Texture::getHostCopyImage | ( | ) | const |
Returns the host-side memory copy of a non-cubemap texture, if available.
Returns as an image the copy of the host-side memory of the default face of a single texture data, but it does not create a copy of that image.
|
inline |
| void kanzi::Texture::resize | ( | size_t | width, |
| size_t | height ) |
Changes the size of the texture.
Texture contents are undefined after resizing, user should assume they are destroyed. Specifying size identical to current size will cause resizing not to happen.
NOTE: Internal API and subject to change or removal.
| width | New width. |
| height | New height. |
Gets width divisor for automatic sizes.
Sets the wight divisor.
| divisor | New width divisor. |
|
inline |
Indicates whether width is or should be automatically calculated.
Gets height divisor for automatic sizes.
Sets the height divisor.
| divisor | New height divisor. |
|
inline |
Indicates whether height is or should be automatically calculated.
|
inline |
Indicates whether render target buffers are transient.
If this flag is set, any renderbuffers associated with depth, stencil or multisampling should be considered lost information at the end of render pass.
|
static |
|
static |
| void kanzi::Texture::recreate | ( | CreateInfo & | createInfo | ) |
Validates the CreateInfo texture descriptor, creates a new texture and swaps it in place.
| createInfo | The texture descriptor. |
Resolves the internal multisample anti-aliasing renderbuffer to a single sample texture, if necessary.
This is required after the rendering is complete if more than one sample is requested. Kanzi blits the contents of the internal MSAA renderbuffer into the texture that can be sampled. If the texture does not have multisampling enabled, this function is a NOP.
| renderer | Renderer. |
|
overrideprotectedvirtual |
Resource::reloadOverride() implementation.
Reimplemented from kanzi::Resource.
|
overrideprotectedvirtual |
Resource::reloadFromKzbOverride() implementation.
Reimplemented from kanzi::Resource.
|
overrideprotectedvirtual |
Resource::reloadFromFileOverride() implementation.
Reimplemented from kanzi::Resource.
|
overrideprotectedvirtual |
Resource::getCPUMemoryUsageOverride() implementation.
Reimplemented from kanzi::Resource.
|
overrideprotectedvirtual |
GPUResource::invalidateOverride() implementation.
Reimplemented from kanzi::GPUResource.
|
overrideprotectedvirtual |
GPUResource::destroyOverride() implementation.
Reimplemented from kanzi::GPUResource.
|
overrideprotectedvirtual |
GpuResource::isDeployed() implementation.
Implements kanzi::GPUResource.
|
overrideprotectedvirtual |
GpuResource::getGPUMemoryUsageOverride() implementation.
Reimplemented from kanzi::GPUResource.
|
overrideprotectedvirtual |
Surface::getFormatOverride() implementation.
Implements kanzi::Surface.
|
overrideprotectedvirtual |
Surface::getRenderTargetSampleCountOverride() implementation.
Implements kanzi::Surface.
|
overrideprotectedvirtual |
Surface::getWidthOverride() implementation.
Implements kanzi::Surface.
|
overrideprotectedvirtual |
Surface::getHeightOverride() implementation.
Implements kanzi::Surface.
|
overrideprotectedvirtual |
Surface::getSliceCountOverride() implementation.
Implements kanzi::Surface.
|
overrideprotectedvirtual |
Surface::getFaceCountOverride() implementation.
Implements kanzi::Surface.
|
overrideprotectedvirtual |
Surface::getMipmapLevelCountOverride() implementation.
Implements kanzi::Surface.
|
staticprotected |
Helper function to allocate host images.
There are three cases:
| createInfo | Texture create info. |
|
protected |
Initialize the texture.
Part of the texture creation and storing of the settings happens in the constructor. This function performs parts of the initialization that do not depend on data in the CreateInfo structure. Kanzi calls this function after the object creation, so it can access shared_from_this() if necessary.
|
protected |
Generate a create info for the texture based on current properties.
| includeImages | Should the CPU images be moved into the create info structure. |
Create internal framebuffers.
Creates both the framebuffer for rendering and the framebuffer for resolving multisamples if necessary. This function needs to be ran if the texture has been resized. The internal parameters must have been updated before calling.
| renderer | Renderer to use for framebuffer creation. |
|
inlineprotected |
Checks if the texture is deployable during construction.
This indicates if the texture should be deployed to the GPU and is not an external texture.
|
friend |
Swaps two textures.
| texture1 | Left-hand-side operand. |
| texture2 | Right-hand-side operand. |
|
protected |
Kanzi graphics image handle.
|
protected |
Overriding sampler create info.
Set by rendering processes that want the texture's sampler settings be temporarily changed. Sampler::CreateInfo is very small, so it's safe to handle as a value type all around.
|
protected |
Framebuffer necessary for compositing into the texture.
This framebuffer is used both for rendering and resolving multisampling.
|
protected |
Format of the texture handle.
This is either a color format or a depth format. Stencil format should never be used.
|
protected |
Texture width.
|
protected |
Texture height.
Divisor for automatic width determination, 0 for no automatic height.
Divisor for automatic height determination, 0 for no automatic height.
|
protected |
Reserved for future use.
Always set to 1. Number of texture slices.
|
protected |
Number of texture faces.
1 for 2D textures, and 6 for cubemap textures
|
protected |
Number of mipmap levels in the texture.
|
protected |
Name to use with the sampler(s) for this texture.
|
protected |
Copy of texture data, provides host CPU access without reading back from GPU.
|
protected |
Image usage flags.
Determines the texture's intended usage. Copied over from the create info.
|
protected |
Memory type for texture.
|
protected |
Native memory storage for the texture.
|
protected |
Texture type.
|
protected |
Number of implicit multisample samples.
|
protected |
Transient flag for renderbuffers generated for off-screen rendering.
If this flag is set and the texture is used as a composition target, renderbuffers will not be preserved for successive render passes.
|
protected |
Depth/Stencil format.
This is depth/stencil format of the additional render buffer in addition to the format in m_format. Both format and depth/stencil format cannot have depth.